<!-- 审核专家 -->
<template>
  <el-dialog :title="title + (disable ? '信息' : '')" :visible.sync="open" width="800px" append-to-body>
    <div class="fz-14 fw-6 color3 linh-40 titleBox">单位基础信息</div>
    <el-descriptions
      :column="2"
      border
      :labelStyle="{ width: '150px', 'white-space': 'nowrap' }"
    >
      <el-descriptions-item label="姓名">
        {{ form.userName }}
      </el-descriptions-item>
      <el-descriptions-item label="性别">
        <dict-tag :options="dict.type.sys_user_sex" :value="form.sex" />
      </el-descriptions-item>
      <el-descriptions-item label="手机号">
        {{ form.mobile }}
      </el-descriptions-item>
      <el-descriptions-item label="所属机构">
        {{ form.com }}
      </el-descriptions-item>
      <el-descriptions-item label="所属科室">
        {{ form.deptName }}
      </el-descriptions-item>
      <el-descriptions-item label="医生头像">
        <image-preview
          v-if="form.headimg"
          :src="form.headimg"
          :width="40"
          :height="40"
        />
      </el-descriptions-item>
    </el-descriptions>
    <div class="fz-14 fw-6 color3 linh-40 titleBox">认证信息</div>
    <el-descriptions
      :column="2"
      border
      :labelStyle="{ width: '150px', 'white-space': 'nowrap' }"
    >
      <el-descriptions-item label="医生职称" :span="24">
        {{ form.postName }}
      </el-descriptions-item>
      <el-descriptions-item label="身份证正面">
        <image-preview
          v-if="form.idcard1"
          :src="form.idcard1"
          :width="60"
          :height="40"
        />
      </el-descriptions-item>
      <el-descriptions-item label="身份证反面">
        <image-preview
          v-if="form.idcard2"
          :src="form.idcard2"
          :width="60"
          :height="40"
        />
      </el-descriptions-item>
      <el-descriptions-item label="医师资格证书">
        <image-preview
          v-if="form.qualificationCertificate"
          :src="form.qualificationCertificate"
          :width="60"
          :height="40"
        />
      </el-descriptions-item>
      <el-descriptions-item label="中医医师执业证书">
        <image-preview
          v-if="form.chineseMedicineQualification"
          :src="form.chineseMedicineQualification"
          :width="60"
          :height="40"
        />
      </el-descriptions-item>
    </el-descriptions>
    <el-divider></el-divider>
    <el-descriptions
      :column="2"
      border
      :labelStyle="{ width: '150px', 'white-space': 'nowrap' }"
    >
      <el-descriptions-item label="创建人">
        {{ form.submitName }}
      </el-descriptions-item>
      <el-descriptions-item label="创建时间">
        {{ form.createTime }}
      </el-descriptions-item>
      <el-descriptions-item label="审核状态">
        <dict-tag :options="dict.type.ap_status" :value="form.apStatus" />
      </el-descriptions-item>
      <el-descriptions-item label="审核备注">
        <span v-if="disable">{{form.apText}}</span>
        <el-input
          v-else
          type="textarea"
          :rows="2"
          placeholder="审核备注,审核驳回时必填"
          v-model="form.apText" />
      </el-descriptions-item>
    </el-descriptions>

    <div v-if="disable" slot="footer" class="dialog-footer">
      <el-button type="primary" @click="open = false">确定</el-button>
    </div>
    <div v-else slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitAdit(1)">审核通过</el-button>
      <el-button type="warning" @click="submitAdit(3)">审核驳回</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { apExpertDetails, aditExpert } from "@/api/expert/ap";
export default {
  dicts: ["ap_status", "sys_user_sex"],
  data() {
    return {
      title: "审核专家",
      open: false,
      form: {},
      disable: false, // 是否禁用
    };
  },
  methods: {
    async openModal(id, type) {
      const that = this;
      that.open = true;
      const { data } = await apExpertDetails(id);
      that.form = { ...data, expertId: id };
      console.log(JSON.parse(JSON.stringify(that.form)));

      that.disable = (type === 'check');
    },
    // 确定审核操作
    submitAdit(apType) {
      if(apType === 3 && !this.form.apText){
        this.$modal.msgError("审核驳回需填写审核备注");
        return
      }
      this.form.apStatus = apType; // 审核状态
      aditExpert(this.form).then((res) => {
        this.$modal.msgSuccess("审核成功");
        this.open = false;
        this.$emit('refresh');
      });
    },
  }
};
</script>

<style lang="scss" scoped>
.titleBox {
  position: relative;
  padding-left: 20px;
  &::before {
    display: block;
    content: " ";
    position: absolute;
    left: 0;
    top: 0;
    transform: translateY(50%);
    width: 4px;
    height: 20px;
    background-color: red;
  }
}
</style>
